function [rank] = initMPIEnvironment(totalNodes)
global masterRank; global Extra; global WORK_TAG; global DIE_TAG;
WORK_TAG = 1;
DIE_TAG = 2;

try
    status = MPI_Init;
    if status ~= MPI_SUCCESS 
        error('Error initializing MPI');
    end
    [status,commSize]=MPI_Comm_size(MPI_COMM_WORLD);
    disp(strcat('Size of the comm',num2str(commSize)));
    % Get the rank of the executing process
    [status rank]= MPI_Comm_rank(MPI_COMM_WORLD);
    if status ~= MPI_SUCCESS 
        error('Error initializing MPI');
    end
    [status pname] = MPI_Get_processor_name;
    if status ~= MPI_SUCCESS 
        error('Error initializing MPI');
    end

%     if dreamPar.verboseOutput
        disp(sprintf('Executing process rank #%d on host %s',rank, pname));
%     end
catch
   rethrow(lasterror) 
end